<script setup>
import { reactive } from 'vue'
import request from '@/utils/request';

const form = reactive({
    name: '',
    gender: '',
    hometown: '',
    judge: false,
    birthday: '',
    post: '',
    experience: ''
})

const onSubmit = async () => {
    var form_obj = JSON.parse(JSON.stringify(form))
    await request.post("/crew_info/add", form_obj).then(res => {

        if (res.code == "200") {
            ElMessage({
                message: '插入成功',
                type: 'success',
            })
        }
    })
}

const cancel = () => {
    for (var key in form) {
        form[key] = null
    }
}
</script>

<template>
    <el-card>
        <div class="app-wrapper">

            <el-form :model="form" label-width="auto" style="max-width: 600px">

                <el-form-item label="姓名">
                    <el-input v-model="form.name" />
                </el-form-item>

                <el-form-item label="性别">
                    <el-select v-model="form.gender" placeholder="please select your gender">
                        <el-option label="男" value="man" />
                        <el-option label="女" value="woman" />
                    </el-select>
                </el-form-item>

                <el-form-item label="籍贯">
                    <el-input v-model="form.hometown" />
                </el-form-item>

                <el-form-item label="是否有相关工作经验">
                    <el-switch v-model="form.judge" />
                </el-form-item>

                <el-form-item label="出生日期">
                    <el-date-picker v-model="form.birthday" type="date" placeholder="出生日期" />
                </el-form-item>

                <el-form-item label="岗位">
                    <el-input v-model="form.post" />
                </el-form-item>
                <el-form-item label="工作经验">
                    <el-input v-model="form.experience" type="textarea" />
                </el-form-item>

                <el-form-item>
                    <el-button type="primary" @click="onSubmit">新增船员信息</el-button>
                    <el-button @click="cancel()">取消</el-button>
                </el-form-item>

            </el-form>


        </div>
    </el-card>
</template>

<style lang="scss" scoped>
</style>